<?xml version="1.0" encoding="UTF-8"?>
<!-- Copyright 2008 XBRL International. All Rights Reserved. -->
<?xml-stylesheet type="text/xsl" href="../stylesheets/conformanceFunction.xsl"?>
<testcase
  xmlns="http://xbrl.org/2008/conformance"
  xmlns:reg="http://xbrl.org/2008/registry"
  xmlns:fcn="http://xbrl.org/2008/function"
  xmlns:cfcn="http://xbrl.org/2008/conformance/function"
  xmlns:xbrli="http://www.xbrl.org/2003/instance"
  xmlns:xhtml="http://www.w3.org/1999/xhtml"
  xmlns:xfi="http://www.xbrl.org/2008/function/instance"
  xmlns:xfie="http://www.xbrl.org/2008/function/instance/error"
  xmlns:xqt-err="http://www.w3.org/2005/xqt-errors"
  xmlns:concept="http://xbrl.org/formula/conformance/example" 
  xmlns:xlink="http://www.w3.org/1999/xlink"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xmlns:xs="http://www.w3.org/2001/XMLSchema"
  xsi:schemaLocation="
  http://xbrl.org/2008/registry ../schemas/registry.xsd
  http://xbrl.org/2008/function ../schemas/function.xsd
  http://xbrl.org/2008/conformance ../schemas/conformance.xsd
  http://xbrl.org/2008/conformance/function ../schemas/conformanceFunction.xsd
  ">
  <owners>
    <reg:owner id="herm">
      <reg:name>Herm Fischer</reg:name>
      <reg:affiliation>UBMatrix / Mark V Systems</reg:affiliation>
      <reg:email>fischer@markv.com</reg:email>
     <reg:assumedOwnership moment="2008-04-06T12:12:00" />
    </reg:owner>
  </owners>

  <number>80153</number>

  <name>xfi:decimals</name>

  <documentation>
    <xhtml:p>
      Test the functionality of the xfi:decimals function.
    </xhtml:p>
    <xhtml:p>
      Suggested conversion from precision to decimals:  If precision is INF, decimals is INF.  If fraction, decimals is INF.  If non-zero precision is reported then decimals is (precision - (floor(log10(value)) + 1)).  If precision 0 is reported, decimals can't really be specified, so there is no clearly correct decimals, but it has been suggested to report INF and allow formulas to execute.  (An "unfriendly" alternate may be to raise an exception.  There is no variation to test precision 0 as it has no meaningful decimals representation.)  
    </xhtml:p>
  </documentation>

  <reference xlink:type="simple" xlink:href="http://www.xbrl.org/Specification/XF-PWD-2006-12-07.htm#_Toc152670664"/>

  <variation id="V-01">
    <name>Returns error for a non-numeric concept</name>
    <documentation>
      <xhtml:p>
        The concept has an xbrli:stringItemType data type.
      </xhtml:p>
     </documentation>
    <inputs>
      <schema xlink:type="simple" xlink:href="decimals-test.xsd"/>
      <instance readMeFirst="true" id="V01" xlink:type="simple" xlink:href="decimals-instance.xml"/>
      <cfcn:call file="V01">
        xfi:decimals( /xbrli:xbrl/concept:c1[1] )
      </cfcn:call>
    </inputs>
    <outputs>
      <error>xfie:ItemIsNotNumeric</error>
    </outputs>
  </variation>

  <variation id="V-02">
    <name>Decimals is 0 for 400, reported as decimals 0</name>
    <documentation>
      <xhtml:p>
      </xhtml:p>
     </documentation>
    <inputs>
      <schema xlink:type="simple" xlink:href="decimals-test.xsd"/>
      <instance readMeFirst="true" id="V02" xlink:type="simple" xlink:href="decimals-instance.xml"/>
      <cfcn:call file="V02">
        xfi:decimals( /xbrli:xbrl/concept:c2[1] )
      </cfcn:call>
    </inputs>
    <outputs>
      <cfcn:test>
         $result instance of xs:integer and $result eq 0
      </cfcn:test>
    </outputs>
  </variation>

  <variation id="V-03">
    <name>Decimals is INF for 400, reported as decimals INF</name>
    <documentation>
      <xhtml:p>
      </xhtml:p>
     </documentation>
    <inputs>
      <schema xlink:type="simple" xlink:href="decimals-test.xsd"/>
      <instance readMeFirst="true" id="V03" xlink:type="simple" xlink:href="decimals-instance.xml"/>
      <cfcn:call file="V03">
        xfi:decimals( /xbrli:xbrl/concept:c2[2] )
      </cfcn:call>
    </inputs>
    <outputs>
      <cfcn:test>
         $result instance of xs:string and $result eq 'INF'
      </cfcn:test>
    </outputs>
  </variation>

  <variation id="V-04">
    <name>Decimals is -2 for 4e2, reported as decimals -2</name>
    <documentation>
      <xhtml:p>
      </xhtml:p>
     </documentation>
    <inputs>
      <schema xlink:type="simple" xlink:href="decimals-test.xsd"/>
      <instance readMeFirst="true" id="V04" xlink:type="simple" xlink:href="decimals-instance.xml"/>
      <cfcn:call file="V04">
        xfi:decimals( /xbrli:xbrl/concept:c2[3] )
      </cfcn:call>
    </inputs>
    <outputs>
      <cfcn:test>
         $result instance of xs:integer and $result eq -2
      </cfcn:test>
    </outputs>
  </variation>

  <variation id="V-05">
    <name>Decimals is 1 for 400, reported as precision 4.</name>
    <documentation>
      <xhtml:p>
        Formula is decimals = (precision - (floor(log10(value)) + 1)) = (4 - (floor(2.6)+1)) = (4 - 3) = 1.
      </xhtml:p>
     </documentation>
    <inputs>
      <schema xlink:type="simple" xlink:href="decimals-test.xsd"/>
      <instance readMeFirst="true" id="V05" xlink:type="simple" xlink:href="decimals-instance.xml"/>
      <cfcn:call file="V05">
        xfi:decimals( /xbrli:xbrl/concept:c2[4] )
      </cfcn:call>
    </inputs>
    <outputs>
      <cfcn:test>
         $result instance of xs:integer and $result eq 1
      </cfcn:test>
    </outputs>
  </variation>

  <variation id="V-06">
    <name>Returns INF for a fraction concept</name>
    <documentation>
      <xhtml:p>
        The concept has an xs:fractionItemType data type.
      </xhtml:p>
     </documentation>
    <inputs>
      <schema xlink:type="simple" xlink:href="decimals-test.xsd"/>
      <instance readMeFirst="true" id="V06" xlink:type="simple" xlink:href="decimals-instance.xml"/>
      <cfcn:call file="V06">
        xfi:decimals( /xbrli:xbrl/concept:c3[1] )
      </cfcn:call>
    </inputs>
    <outputs>
      <cfcn:test>
         $result instance of xs:string and $result eq 'INF'
      </cfcn:test>
    </outputs>
  </variation>

  <variation id="V-07">
    <name>Returns error for a tuple concept</name>
    <documentation>
      <xhtml:p>
        The concept is a tuple.
      </xhtml:p>
     </documentation>
    <inputs>
      <schema xlink:type="simple" xlink:href="decimals-test.xsd"/>
      <instance readMeFirst="true" id="V07" xlink:type="simple" xlink:href="decimals-instance.xml"/>
      <cfcn:call file="V07">
        xfi:decimals( /xbrli:xbrl/concept:c4[1] )
      </cfcn:call>
    </inputs>
    <outputs>
      <error>xqt-err:XPTY0004</error>
    </outputs>
  </variation>

  <revisions>
    <reg:revision on="2008-04-06T12:12:00" by="herm">
      <xhtml:p>
        Created the test case.
      </xhtml:p>
    </reg:revision>
    <reg:revision on="2011-06-22T00:00:00" by="herm">
      <xhtml:p>
        Added xmlns:xs.
      </xhtml:p>
    </reg:revision>
  </revisions>

</testcase>

